package pdm.traj.data;

import java.util.ArrayList;
import java.util.List;

public class Track {
	private String id;
	public int support;
	public int len = 0;
	public double interestingRate;
	private ArrayList<TrackPoint> trackPoints = new ArrayList<TrackPoint>();
	private ArrayList<User> users = new ArrayList<User>();
	
	private static int idcount=0;
	public float ratio;//support ratio
	
	public Track(){
		this.id= String.valueOf(idcount);
		idcount++;
		if(idcount<0) idcount=0;
		
		this.support=1;
		this.ratio=0.0f;
		this.interestingRate=0.0f;
	}
	public Track(int sup,float ratio,float score){
		this.id=String.valueOf(idcount);
		idcount++;
		if(idcount<0) idcount=0;
		
		this.support=sup;
		this.ratio=ratio;
		this.interestingRate=score;
	}
	
	public void addPoint(TrackPoint p){
		trackPoints.add(p);
		this.len ++;
	}
	
	public void addPoint(String date, String time, double lat, double lng){
		TrackPoint p = new TrackPoint(date, time, lat, lng);
		trackPoints.add(p);
		this.len ++;
	}
	
	public void addPoint(String time, double lat, double lng){
		TrackPoint p = new TrackPoint(time, lat, lng);
		trackPoints.add(p);
		this.len ++;
	}
	
	//TODO
	public boolean removePoint(){
		return false;
	}
	
	public void insertPoint(int index, TrackPoint p){
		trackPoints.add(index, p);
		this.len ++;
	}
	
	public String getId(){
		return this.id;
	}
	
	public void setId(String id){
		this.id = id;
	}

	public void setId(int id){
		this.id = String.valueOf(id);
	}
	
	public void setSupport(int sup) {
		this.support = sup;
	}

	public int getSupport() {
		return this.support;
	}

	public void setRatio(float ratio) {
		this.ratio = ratio;
	}

	public float getRatio() {
		return ratio;
	}

	public void setScore(float score) {
		this.interestingRate = score;
	}
	
	public ArrayList<TrackPoint> getTrackPoints(){
		return this.trackPoints;
	}
	
	public ArrayList<User> getUsers(){
		return this.users;
	}
	
	public Track clone(){
		Track t = new Track();
		t.setId(this.id);
		t.interestingRate = this.interestingRate;
		t.len = this.len;
		t.support = this.support;
		for(TrackPoint p : this.getTrackPoints()){
			t.getTrackPoints().add(p);
		}
		for(User u : this.getUsers()){
			t.getUsers().add(u);
		}
		return t;
	}
}
